using System;
using TMPro;
using UnityEngine;

namespace Client.Base
{
    
    public class LocalizationTMP : MonoBehaviour
    {
        [SerializeField] private string key;
        private TextMeshProUGUI tmp;
        private void Start()
        {
            tmp = GetComponent<TextMeshProUGUI>();
            Localization.onChange += OnChange;
            OnChange();
        }

        private void OnChange()
        {
            if (tmp)
            {
                tmp.text = Localization.GetContent(key);
            }
        }
    }

}
